package com.mera.tektronix.csviewer.domain



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Person)
class PersonTests {

	Person person
	
	@Before
	void setUp() {
		mockForConstraintsTests(Person)
		person = new Person(name: "Person", birthDate: new Date("1980/11/11"));
	}
	
	void testConstraintsNameBlank() {
		person.name = ""
		assertFalse person.validate()
		assertEquals 'blank', person.errors['name']

		person.name = "Project"
		assertTrue person.validate()
		assertNull person.errors['name']
	}
	
	void testConstraintsBirthDateNullable() {
		person.birthDate = null
		assertFalse person.validate()
		assertEquals 'nullable', person.errors['birthDate']

		person.birthDate = new Date("1980/11/11");
		assertTrue person.validate()
		assertNull person.errors['birthDate']
	}
}
